--------------------------------
-- 组封装
-------------------------------
local M = {}

-- 获取当前场景组
function M.newGroup(parent)
	local group = display.newGroup()
	if parent then
		parent:insert(group)
	end
	return group
end

-- 是否为一个display对象
function isObj(obj)
	if not obj then
		return false
	end

	return not obj._isRemove and obj._proxy and obj.removeSelf
end

-- 判定是否为组
function M.isGroup(obj)
	if not obj then
		return false
	end
	return not obj._isRemove and obj._proxy and obj.removeSelf
end

-- 删除子物体
function M.removeChildren(obj)
	for i = obj.numChildren, 1, -1  do
		if obj[i].removeSelf then
			obj[i]:removeSelf()
			obj[i] = nil
		end
	end
end

-- 删除自己
function M.remove(obj)
	if not obj then
		return
	end

	obj._isRemove = true

	if obj.removeSelf then
		obj:removeSelf()
	end
	obj = nil
end

return M